//
//  WuyefuwuViewController.m
//  wuyeviewcon
//
//  Created by dsdf on 16/1/11.
//  Copyright © 2016年 joey. All rights reserved.
//

#import "WuyefuwuViewController.h"
#import "JRSegmentViewController.h"

#import "FirstViewController.h"
#import "SecondViewController.h"
#import "textdemoViewController.h"
#import "teyuebaoxiuViewController.h"
#import "gonggongbaoxiuViewController.h"




@interface WuyefuwuViewController ()<UIScrollViewDelegate>
{
    UIScrollView * _scrollView;
    UIPageControl * _pageControl;
    
    UIScrollView * lableScrollView;
    UIImageView * titltImgView;
    BOOL isFlag;
   // xialaView * _xiala;
    BOOL isNo;
    //AddView * _addView;

    
}


@end

@implementation WuyefuwuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationController.navigationBar.barTintColor = [[UIColor alloc] initWithRed:230/255.0 green:55/255.0 blue:55/255.0 alpha:1.0];
    
    self.navigationItem.title=@"物业服务";
    self.navigationController.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:17]};
   
 
    
    
    //self.navigationItem.title = @"星河生活家";
    UIImage * img0 = [UIImage imageNamed:@"矩形-18@2x.png"];
    UIImage * img1 = [UIImage imageNamed:@"矩形-18@2x.png"];
    UIImage * img2 = [UIImage imageNamed:@"矩形-18@2x.png"];
    UIImage * img3 = [UIImage imageNamed:@"矩形-18@2x.png"];
    UIImage * img4 = [UIImage imageNamed:@"矩形-18@2x.png"];
    [self.view addSubview:[self scrollViewWithNSArray:@[img0,img1,img2,img3,img4]]];
    
    
    _pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 216, self.view.frame.size.width, 40)];
    _pageControl.numberOfPages = 5;
    _pageControl.currentPageIndicatorTintColor = [UIColor redColor];
    _pageControl.pageIndicatorTintColor = [UIColor clearColor];
    [_pageControl addTarget:self action:@selector(changePages) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:_pageControl];
    
    /*NSTimer * timer0= */[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(onTime) userInfo:nil repeats:YES];

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 图片滑动视图
-(UIScrollView *)scrollViewWithNSArray:(NSArray *)imageArray {
    
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 86, self.view.frame.size.width, 192)];
    _scrollView.pagingEnabled = YES;
    _scrollView.contentSize = CGSizeMake(self.view.frame.size.width*imageArray.count, 192);
    self.automaticallyAdjustsScrollViewInsets = NO;
    for (int i =0; i<imageArray.count;i++) {
        UIButton * imageButton = [UIButton buttonWithType:UIButtonTypeCustom];
        imageButton.frame = CGRectMake(self.view.frame.size.width*i, 0, self.view.frame.size.width, 192);
        [imageButton setImage:[imageArray objectAtIndex:i] forState:UIControlStateNormal];
        imageButton.tag = i;
        [imageButton addTarget:self action:@selector(scrollViewImageButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [_scrollView addSubview:imageButton];
        
    }
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.showsVerticalScrollIndicator = NO;
    
    //设置代理
    _scrollView.delegate = self;
    
    
    return _scrollView;
}

#pragma mark - 点击pageControl方法
-(void)changePages {
    [_scrollView setContentOffset:CGPointMake(_pageControl.currentPage*self.view.frame.size.width, 0) animated:YES];
}

#pragma mark - 定时器方法
//图片定时器
-(void)onTime {
    static int speed=1;
    _pageControl.currentPage+=speed;
    if (_pageControl.currentPage==2||_pageControl.currentPage==0) {
        speed=-speed;
    }
    [_scrollView setContentOffset:CGPointMake(_pageControl.currentPage*self.view.frame.size.width, 0) animated:YES];
}

#pragma mark - 点击滑动视图上的图片的方法
-(void)scrollViewImageButtonClick:(UIButton *)imageButton {
    //    NSLog(@"image=%ld",(long)imageButton.tag);
}


- (IBAction)telephonenum:(id)sender {
    //电话
    //tousujianyiViewController *demoVC=[[tousujianyiViewController alloc]init];
   //[self transitionWithType:demoVC WithSubtype:subtypeString ForView:self.view];
    
    NSString *str = [NSString stringWithFormat:@"tel:%@",@"18749627117"];
    
    UIWebView *callWebView = [[UIWebView alloc]init];
    
    [callWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
    
    [self.view addSubview:callWebView];
    

}

- (IBAction)tousujianyi:(id)sender {
    //投诉建议
//    tousujianyiViewController *demoVC=[[tousujianyiViewController alloc]init];
//    [demoVC setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
//    [self.navigationController pushViewController:demoVC animated:YES];
//    //[self presentModalViewController:demoVC animated:YES ];
//  
    FirstViewController *firstVC = [[FirstViewController alloc] init];
    SecondViewController *secondVC = [[SecondViewController alloc] init];
    
    JRSegmentViewController *vc = [[JRSegmentViewController alloc] init];
    vc.segmentBgColor = [UIColor redColor];//colorWithRed:18.0f/255 green:50.0f/255 blue:110.0f/255 alpha:1.0f];
    //vc.indicatorViewColor = [UIColor redColor];
    vc.titleColor = [UIColor whiteColor];
    
    [vc setViewControllers:@[firstVC, secondVC]];
    [vc setTitles:@[@"投诉建议", @"我的投诉"]];
    [vc setHidesBottomBarWhenPushed:YES];
    [self.navigationController pushViewController:vc animated:YES];
    
    
    
    
}


- (IBAction)gonggongbaoxiu:(id)sender {
    
    gonggongbaoxiuViewController *demoVC=[[gonggongbaoxiuViewController alloc]init];
    demoVC.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
    [self presentViewController:demoVC animated:YES completion:NULL];
    
    
//    textdemoViewController *demoVC=[[textdemoViewController alloc]init];
//    demoVC.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
//    [self presentViewController:demoVC animated:YES completion:NULL];

    
}

- (IBAction)zhangdan:(id)sender {
    
    
    textdemoViewController *demmoVC=[[textdemoViewController alloc]init];
    demmoVC.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
    [self presentViewController:demmoVC animated:YES completion:NULL];
    
    
    
}
- (IBAction)teyuebaoxiu:(id)sender {
    teyuebaoxiuViewController *demoVC=[[teyuebaoxiuViewController alloc]init];
    [demoVC setHidesBottomBarWhenPushed:YES];
    [self presentViewController:demoVC animated:YES completion:NULL];    
    
}

//#pragma mark - 点击标题的方法
//-(void)titleClick {
//    isFlag = !isFlag;
//    
//    if (isFlag) {
//        //        titltImgView.transform = CGAffineTransformMakeRotation(M_PI);
//        [self.view addSubview:_xiala];
//        
//    }else {
//        //        titltImgView.transform =CGAffineTransformIdentity;
//        [_xiala removeFromSuperview];
//    }
//    
//}
//



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
